package com.bos.controller;

import com.bos.controller.base.BaseController;
import com.bos.controller.base.imp.BaseControllerImp;
import com.bos.domain.Workordermanage;
import com.bos.service.WorkOrderManagerService;
import com.bos.utils.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Administrator
 */

@Controller
public class WorkOrderManagerController extends BaseControllerImp<Workordermanage> implements BaseController<Workordermanage> {


    @Autowired
    private WorkOrderManagerService workBillService;

    @Autowired
    WorkOrderManagerController(PageBean pageBean){
        super(pageBean);
    }

    /**快速保存工作单
     * */
    @RequestMapping(value = "/quickSaveWorkOrderBill",method = RequestMethod.POST)
    @ResponseBody
    public String addWorkBill(Workordermanage  workordermanage){
        workBillService.save(workordermanage);
        return "";
    }

    /**删除工作单(批量),当前台要传输一个json数组字符串回来时，如果封装不了要用@requestbody将json字符串反序列化为对象数组,
     *
     * */
    @RequestMapping(value = "/deleteWorkOrderBill",method = RequestMethod.POST)
    @ResponseBody
    public String deleteWorkBill(@RequestBody Workordermanage [] workordermanage){
        String flag = "1";
        try {
            workBillService.delete(workordermanage);
        } catch (Exception e) {
            flag = "0";
            e.printStackTrace();
        }
        return flag;
    }
}
